-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[lld][WebAssembly] Improve -v/-V/--version flag compat #113204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-lld-wasm @llvm/pr-subscribers-lld Author: Sam Clegg (sbc100) ChangesFixes: #112836 Full diff: https://github.com/llvm/llvm-project/pull/113204.diff 3 Files Affected:
diff --git a/lld/test/wasm/version.test b/lld/test/wasm/version.test
new file mode 100644
index 00000000000000..54a80976552559
--- /dev/null
+++ b/lld/test/wasm/version.test
@@ -0,0 +1,12 @@
+## Copied from lld/test/ELF/version.test
+
+## --version skips input file processing.
+# RUN: wasm-ld --version %t/not-exist 2>&1 | FileCheck %s
+
+## -v/-V don't skip processing if there is any input.
+# RUN: wasm-ld -v 2>&1 | FileCheck %s
+# RUN: not wasm-ld -v %t/not-exist 2>&1 | FileCheck %s
+# RUN: wasm-ld -V 2>&1 | FileCheck %s
+# RUN: not wasm-ld -V %t/not-exist 2>&1 | FileCheck %s
+
+# CHECK: LLD {{.+}}
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 289c1217ff5ead..9a27fc90457f08 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -1218,11 +1218,9 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
return;
}
- // Handle --version
- if (args.hasArg(OPT_version) || args.hasArg(OPT_v)) {
+ // Handle -v or -version.
+ if (args.hasArg(OPT_v) || args.hasArg(OPT_version))
lld::outs() << getLLDVersion() << "\n";
- return;
- }
// Handle --reproduce
if (const char *path = getReproduceOption(args)) {
@@ -1248,6 +1246,13 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
readConfigs(args);
setConfigs();
+ // The behavior of -v or --version is a bit strange, but this is
+ // needed for compatibility with GNU linkers.
+ if (args.hasArg(OPT_v) && !args.hasArg(OPT_INPUT))
+ return;
+ if (args.hasArg(OPT_version))
+ return;
+
createFiles(args);
if (errorCount())
return;
diff --git a/lld/wasm/Options.td b/lld/wasm/Options.td
index c5febd145a54f3..cff29e709a1a09 100644
--- a/lld/wasm/Options.td
+++ b/lld/wasm/Options.td
@@ -288,6 +288,7 @@ def: Flag<["-"], "S">, Alias<strip_debug>, HelpText<"Alias for --strip-debug">;
def: Flag<["-"], "t">, Alias<trace>, HelpText<"Alias for --trace">;
def: JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>, HelpText<"Alias for --trace-symbol">;
def: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
+def: Flag<["-"], "V">, Alias<v>, HelpText<"Alias for -v">;
// LTO-related options.
def lto_O: JJ<"lto-O">, MetaVarName<"<opt-level>">,
|
dschuff
approved these changes
Oct 22, 2024
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/6950 Here is the relevant piece of the build log for the reference
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #112836